
import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const Home = () => import ("@/views/Home")


const routes = [{
        path: "/",
        redirect: "/map"
    },
    {
        path: "/map",
        name: "map",
        meta: {
            title: "长兴中心广场智慧商圈",
        },
        component: Home
    }
]


const router = new VueRouter({
    mode: "history",
    routes,
    scrollBehavior(to, from, savePosition) {
        if (savePosition) {
            return savePosition
        } else {
            return { x: 0, y: 0 };
        }
    },
})




router.beforeEach((to, from, next) => {
    next()
})

router.afterEach((to, from) => {
    to.meta.title && (document.title = to.meta.title)
})

export default router